package com.iqi.onigao.module;

import java.util.Set;

import com.iqi.onigao.context.BeanFactory;

import cn.hutool.core.lang.ClassScaner;
import net.IModule;
import net.SIOHandler;

/**
 * 协议模块管理器
 * 
 * @author zhou.liu
 *
 */
public class SIOSimpleHandler extends SIOHandler {

	public final static SIOSimpleHandler INS = new SIOSimpleHandler();

	private SIOSimpleHandler() {
	}

	/**
	 * 注册模块
	 */
	@Override
	public boolean init() {
		Set<Class<?>> moudleClasses = ClassScaner.scanPackage("com.iqi.onigao", (c) -> {
			return IModule.class.isAssignableFrom(c) && c.isInterface();
		});
		for (Class clazz : moudleClasses) {
			add((IModule) BeanFactory.getInstance().getBean(clazz));
		}
		return true;
	}
}
